package demo.demo10;

public class test04 {
    public static void main(String[] args) throws ClassNotFoundException {
        Person person = new Person();
        System.out.println("是：" + person.name);
        //通过对象获取
        Class c1 = person.getClass();
        System.out.println(c1.hashCode());
        //fromName
        Class c2 = Class.forName("demo.demo10.User01");
        System.out.println(c2.hashCode());
        //通过类名。class
        Class<Student> studentClass = Student.class;
        System.out.println(studentClass.hashCode());
        //基本内置类型的包装类都有一个Type属性
        Class<Integer> type = Integer.TYPE;
        System.out.println(type.hashCode());

        //获得父类的类型
        Class superclass = c1.getSuperclass();
        System.out.println(superclass.hashCode());

    }
}

class Person {
    public String name;

    public Person() {
    }

    public Person(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                '}';
    }
}

class Student extends Person {
    public Student() {
        this.name = "学生";
    }
}

class Teacher extends Person {
    public Teacher() {
        this.name = "老师";
    }
}